package view;

import java.util.Scanner;

public class GetGameInfo {
	Scanner sc = new Scanner(System.in);

	public String getPlayersName(int index) {
		String name = null;
		do {
			String player = compOrPlayer(index);
			System.out.println("Enter " + player + " name: ");
			name = sc.next();
		} while (!playerNameIsCorrect(name));
		return name;
	}

	public char getPlayersMark(int index) {
		char mark;
		String player = compOrPlayer(index);
		do {
			System.out.println("Enter " + player + " mark(a-Z): ");
			String markString = sc.next();
			mark = markString.toUpperCase().charAt(0);
			System.out.println(mark);
		} while (!playerMarkIsCorrect(mark));
		return mark;
	}

	private boolean playerNameIsCorrect(String name) {
		return (name != null && name.length() > 0);
	}

	private boolean playerMarkIsCorrect(char mark) {
		return (mark >= 'A' && mark <= 'Z');
	}
	

	private String compOrPlayer(int index) {
		String player;
		if(index == 0) {
			player = "player";
		} else {
			player = "computer";
		}
		return player;
	}
}